import React from 'react';
import { createForm } from 'rc-form';
import { WhiteSpace } from 'antd-mobile';
import { Link,hashHistory} from 'react-router';
import { List } from 'antd-mobile';
import 'antd-mobile/dist/antd-mobile.css';

const Item = List.Item;
const Brief = Item.Brief;
let userMsg = {};
class MyMenu extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            pickerValue: [],
            dpValue: null,
            imageUrl:''
        };
    }
    componentDidMount() {
        // console.log(this.props);
        // this.props.changeTitle('我的');
    }

    componentWillMount(){

        // userMsg = this.props.location.state;
        // if (userMsg !== undefined){
        //     this.setState({
        //         imageUrl:userMsg.user_picture === undefined ? 'http://192.168.0.131:8091/ecommerce/20171115103252.png' : userMsg.user_picture
        //     })
        // }
    }

    //查看会员信息
    userDetail = (e) => {
        hashHistory.push({
            pathname: '/user/usersetting',
            // state: userMsg
        })
    }
    render() {

        // 获取登录状态
        const isLogin = localStorage.getItem("isLogin");
        console.log(isLogin);
        if (isLogin == 0) {
            return (
                <div>
                    <ul>
                        <li><Link to="/login">登录/注册</Link></li>
                    </ul>
                </div>
            );
        } else {

            //获取用户信息
            // const userName = userMsg.user_name;
            const userName = 1;
            return (
                <div>
                    <WhiteSpace/>
                    <WhiteSpace/>
                    <span onClick={this.userDetail.bind(this)}>
                        <List className="my-list">
                            <Item align="top" thumb={this.state.imageUrl} multipleLine>
                                {userName} <Brief>subtitle</Brief>
                            </Item>
                        </List>
                    </span>
                </div>
            );
        }
    }
}

export default MyMenu;
